package com.lock.lock_common.api.order;

import com.github.pagehelper.PageInfo;
import com.lock.lock_common.dto.Result;
import com.lock.lock_common.pojo.*;
import com.lock.lock_common.utils.MRegion;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

public interface OrderApi {
    /**
     * 根据订单ID查询该订单
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/getOrder")
    Result<Order> getOrder(@RequestParam(value = "orderId") Integer orderId);

    /**
     * 查询订单没有安装人员接单时的状态
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/getOrderNoInstaller")
    Result<Order> getOrderNoInstaller(@RequestParam(value = "orderId") Integer orderId);

    /**
     * 查询用户的所有订单，不包括删除状态为1的订单
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getOrderByUserId")
    Result<PageInfo<Order>> getOrderByUserId(@RequestParam(value = "userId") Integer userId,@RequestParam(value = "pageNo") Integer pageNo,@RequestParam(value = "pageSIze") Integer pageSize);

    /**
     * 用户生成订单是查看订单号是否已经存在
     * @param orderNum
     * @return
     */
    @RequestMapping(value = "/getOrderNum")
    Result<Boolean> getOrderNum(@RequestParam(value = "orderNum") String orderNum);

    /**
     * 查询地址
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getAddress")
    Result<Region> getAddress(@RequestParam(value = "userId") Integer userId,
                              @RequestParam(value = "regionId",required = false) Integer regionId,
                              @RequestParam(value = "addressId",required = false) Integer addressId);

    /**
     * 添加订单
     * @param order
     * @return
     */
    @RequestMapping(value = "/insertOrder")
    Result<Integer> insertOrder(@RequestBody Order order);

    /**
     * 修改订单
     * @param order
     * @return
     */
    @RequestMapping(value = "/updOrder")
    Result<Boolean> updOrder(Order order);

    /**
     * 删除订单
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/delOrder")
    Result<Boolean> delOrder(@RequestParam(value = "orderId") Integer orderId);

    /**
     * 查询用户未支付的订单
     * @param UserId
     * @return
     */
    @RequestMapping(value = "/getNotPay")
    Result<PageInfo<Order>> getNotPay(@RequestParam(value = "UserId") Integer UserId,@RequestParam(value = "pageNo") Integer pageNo,@RequestParam(value = "pageSIze") Integer pageSize);

    /**
     * 查询用户未安装的订单
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getNotInstall")
    Result<PageInfo<Order>> getNotInstall(@RequestParam(value = "userId") Integer userId,@RequestParam(value = "pageNo") Integer pageNo,@RequestParam(value = "pageSIze") Integer pageSize);

    /**
     * 查询未评价的订单
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getNotEvalua")
    Result<PageInfo<Order>> getNotEvalua(@RequestParam(value = "userId") Integer userId,@RequestParam(value = "pageNo") Integer pageNo,@RequestParam(value = "pageSIze") Integer pageSize);

    /**
     * 查询商品有哪些优惠
     * 返回List，如果List为空，这表示该商品没有优惠
     * @param productId
     * @return
     */
    @RequestMapping(value = "/getProduct")
    Result<List<ProductDiscounts>> getProduct(@RequestParam(value = "userId") Integer productId);

    /**
     * 根据商品ID查询该商品是否存在于优惠表
     * @param productId
     * @return
     */
    @RequestMapping(value = "/getProductDiscounts")
    Result<ProductDiscounts> getProductDiscounts(@RequestParam(value = "productId") Integer productId);

    /**
     * 查询商品价格
     * @param productId
     * @return
     */
    @RequestMapping(value = "/getProductPrice")
    Result<Double> getProductPrice(@RequestParam(value = "productId") Integer productId);

    /**
     * 管理人员模糊分页查询所有订单,
     * Account可以是用户名，也可以是订单
     * @param Account
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/getAllOrder")
    Result<PageInfo<Order>> getAllOrder(@RequestParam(value = "Account") String Account,
                                        @RequestParam(value = "pageNo") Integer pageNo,
                                        @RequestParam(value = "pageSize") Integer pageSize,
                                        @RequestParam(value = "userId") Integer userId);

    /**
     * 用户确认订单安装完成
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/an")
    Result<Boolean> an(@RequestParam(value = "orderId") Integer orderId);

    /**
     * 添加评论
     * @param orderInstaller
     * @return
     */
    @RequestMapping(value = "/getEvalua")
    Result<Boolean> getEvalua(@RequestBody OrderInstaller orderInstaller);

    /**
     * 查询订单下是否有安装人员
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/getInstaller")
    Result<Boolean> getInstaller(@RequestParam(value = "orderId") Integer orderId);

    /**
     * 查询用户所有的收货地址
     * @param userId
     * @return
     */
    @RequestMapping(value = "/getAllAddress")
    Result<List<MRegion>> getAllAddress(@RequestParam(value = "userId") Integer userId);

    /**
     * 查询用户填写的订单是否存在
     * @param invitedNum
     * @return
     */
    @RequestMapping(value = "/getInvi")
    Result<Boolean> getInvi(Integer invitedNum);

    /**
     * 查询所有没有安装人员的订单
     * @return
     */
    @RequestMapping(value = "/getAllOrderNotInstaller")
    Result<PageInfo<Order>> getAllOrderNotInstaller(@RequestParam(value = "pageNo") Integer pageNo,
                                                    @RequestParam(value = "pageSize") Integer pageSize,
                                                    @RequestParam(value = "dealersId") Integer dealersId);

    /**
     * 安装人员抢单
     * @param installerId
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/addEvalua")
    Result<Boolean> addEvalua(@RequestParam(value = "installerId") Integer installerId,@RequestParam(value = "orderId") Integer orderId);

    /**
     * 查询当前是否有全部商品都参加的满减活动
     * @return
     */
    @RequestMapping(value = "/getTypeTwo")
    Result<ProductDiscounts> getTypeTwo();

    /**
     * 查询商品信息
     * @param productId
     * @param price
     * @return
     */
    @RequestMapping(value = "/getProductOne")
    Result<Product> getProductOne(@RequestParam(value = "productId") Integer productId,@RequestParam(value = "price") BigDecimal price);

    /**
     * 查询安装人员现在是否已经接单
     * @param installerId
     * @return
     */
    @RequestMapping(value = "/getOrderInstaller")
    Result<Boolean> getOrderInstaller(@RequestParam(value = "installerId") Integer installerId);

    /**
     * 安装人员删除订单
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/delOrderInstaller")
    Result<Boolean> delOrderInstaller(@RequestParam(value = "orderId") Integer orderId);

    /**
     * 安装人员查看自己的满意度和评价
     * @param installerId
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/getOrderStar")
    Result<PageInfo<Order>> getOrderStar(@RequestParam(value = "installerId") Integer installerId,
                                         @RequestParam(value = "orderNum") String orderNum,
                                         @RequestParam(value = "star") Integer star,
                                         @RequestParam(value = "pageNo") Integer pageNo,
                                         @RequestParam(value = "pageSize") Integer pageSize);

    /**
     * 查询安装人员待安装的订单
     * @param installerId
     * @return
     */
    @RequestMapping(value = "/getNoInstaller")
    Result<Order> getNoInstaller(@RequestParam(value = "installerId") Integer installerId);

    /**
     * 安装人员查询已安装的订单
     * @param installerId
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/getInstalled")
    Result<PageInfo<Order>> getInstalled(@RequestParam(value = "installerId") Integer installerId,
                                         @RequestParam(value = "orderNum") String orderNum,
                                         @RequestParam(value = "pageNo") Integer pageNo,
                                         @RequestParam(value = "pageSize") Integer pageSize);

    /**
     * 查询经销商当月销量
     * regionId判断系统管理员还是经销商
     * flag不为空，则查询当月已完成的订单
     * 为空，则查询当月全部订单
     * @param regionId
     * @param flag
     * @return
     */
    @RequestMapping(value = "/getSales")
    Result<Integer> getSales(@RequestParam(value = "regionId",required = false) Integer regionId,
                             @RequestParam(value = "flag",required = false) Integer flag);

    /**
     * 付款完毕后增加销量，并减少库存
     * @param productId
     * @param count
     * @return
     */
    @RequestMapping(value = "/updProductNum")
    Result<Boolean> updProductNum(@RequestParam(value = "productId") Integer productId,
                                  @RequestParam(value = "count") Integer count);

    /**
     * 邀请码次数增加
     * 当前订单用户没有邀请码时，先生成邀请码，再把用户填写的邀请码次数加（当前订单商品总数量）次
     * 当前订单用户有邀请码，把用户填写的邀请码次数加（当前订单商品总数量）次
     * @return
     */
   /* @RequestMapping(value = "/addInvited")
    Result<Boolean> addInvited(@RequestBody Order order);*/

   @RequestMapping(value = "/getStock")
   Result<Integer> getStock(@RequestParam(value = "productId") Integer productId);

    /**
     * 查询安装人员是否是黑名单状态
     * @param installerId
     * @return
     */
   @RequestMapping(value = "/getStar")
   Result<Boolean> seleteStar(@RequestParam(value = "installerId") Integer installerId);

    /**
     * 管理人员点击付款
     * @param productSales
     * @return
     */
   @RequestMapping(value = "/UpdateStock")
   Result<Boolean> UpdateStock(@RequestBody ProductSales productSales);

}
